<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:replace="dashboard/header :: header"></head>

<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="operlog-form">
					<div class="select-list">
						<ul>
							<li>
								<label>所属应用： </label><input type="text" name="applicationId"/>
							</li>
							<li>
								<label>角色名称： </label><input type="text" name="condition[roleName|like]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()">
					<i class="fa fa-plus"></i> 新增
				</a>
				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()">
		            <i class="far fa-trash-alt"></i> 删除
		        </a>
	            <a class="btn btn-warning" onclick="$.table.exportExcel()">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
	        
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	
	<footer th:replace="dashboard/footer :: footer"></footer>

	<script>
		$(function() {
		    var options = {
		        url: ctx+"portal/ucenter/role/datatables" ,
		        createUrl: ctx + 'portal/ucenter/role/add' ,
		        updateUrl: ctx+"portal/ucenter/role/modify?id={id}" ,
		        statusUrl: ctx+"portal/ucenter/role/changeStatus?id={id}" , 
		        detailUrl: ctx+"portal/ucenter/role/detail?id={id}",
		        removeUrl: ctx+"portal/ucenter/role/delete" ,
		        exportUrl: ctx + "portal/ucenter/role/exportExcel",
		        sortName: "operTime",
		        uniqueId:"id" ,
		        sortOrder: "desc",
		        modalName: "角色",
		        escape: true,
		        showPageGo: true,
		        rememberSelected: true,
		        columns: [{field: 'state',checkbox: true },
					{field: 'id', title: '序号' , align:'center' , width:'30px', formatter: function(v , r , i){return i + 1 ;}},
		        	{field: 'applicationIdLabel', title: '所属应用'},
			        {field: 'roleName', title: '角色名称'},
			        {field: 'roleDesc', title: '角色描述'},
			        {field: 'hasStatusLabel', title: '状态', align: 'center',  formatter:function(value,row,index){ return $.table.status(value , row);}},
			        {field: 'id', title: '权限',  align: 'center',  formatter: function(value, row, index) {
		                	var actions = [];
		                	actions.push("<a style='cursor:pointer' data-id='"+value+"' onclick='showMember(this)'><i class='fas fa-users'></i> 成员管理</a>");
		                	return actions.join('');
		          		}
			        },
			        {field: 'updateTime' , title: '操作',  align: 'center',  formatter: function(value, row, index) {
			                var actions = [];
			                
			                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
			                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="far fa-trash-alt"></i>删除</a> ');

			                return actions.join('');
			          }
			     	}]
		    };
		    $.table.init(options);
		});
		
		function showMember(self){
			var id = $(self).attr("data-id") ; 
			$.modal.open("会员列表", ctx+"portal/ucenter/role/member?roleId=" + id, null, null, function(index , layer){
				
			}) ;
		}
		
	</script>
</body>
</html>